<template>
  <div @click="selectBox">
	<span class="checkbox"
          :class="{
              'checked': !!checked,
              'disabled': !!disabled
			}"
    >
        <i
            class="checkbox__tick iconfont icon-duigou1"
            :class="{
              'checked': !!checked,
              'disabled': !!disabled
            }"
        ></i>
        <input class="checkbox__model" type="checkbox"
              v-model="checked"
              :value="value"
              readonly
        >
    </span>
  </div>
</template>
<script>
export default {
  name: "Checkbox",
  props: ["model", "value", "disabled", "checkClick"],
  data() {
    return {
	  checked: this.model,
    };
  },
  created () {
	   
  },
  mounted() {},
  methods: {
    selectBox() {
      if(this.disabled) {
        this.checked = false;
      } else {
        this.checked = !this.checked;
      }
      this.$emit('checkClick');
    }
  },
  watch: {
    checked(n) {
      let value = n ? this.value || n : n;
      this.$emit("update:model", value);
    },
    model(n) {
      this.checked = n;
    }
  },
  computed: {}
};
</script>
<style lang="scss" scoped>
$themeColor: #e50838;

.checkbox {
  display: inline-block;
  width: 0.36rem;
  height: 0.36rem;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid #999;
  position: relative;
  background-color: #fff;
  text-align: center;
  line-height: 0.36rem;
  vertical-align: baseline;
  &__model {
    opacity: 0;
    display: none;
  }
  &__tick {
    font-size: 0.36rem;
    // -webkit-text-stroke-width: 0.02rem;
    color: #fff;
    position: absolute;
    left: -0.01rem;
    top: -0.02rem;
    &.checked {
    }
    &.disabled {
      color: #ccc;
    }
  }
  &.checked {
    overflow: hidden;
    position: relative;
    background-color: $themeColor;
    border: 1px solid $themeColor;
  }
  &.disabled {
    border: 1px solid #ccc;
    background-color: #ccc;
  }
}
</style>
